<template>
    <div class="playList">
        <div class="playList-top">
            <div class="left" @click="play(0)">
                <svg class="icon" aria-hidden="true">
                    <use xlink:href="#icon-bofang3"></use>
                </svg>
            <div class="title">播放全部<span>(共{{playlist.tracks.length}}首)</span></div>
            </div>
                <div class="btn">
                    + 收藏（{{changeValue(playlist.subscribedCount)}}）
                </div>
        </div>
        <div class="list" >
            <div class="playitem" v-for="(item,i) in playlist.tracks" :key="i" @click="play(i)">
                <div class="left">
                    <div class="index">{{i+1}}</div>
                    <div class="content">
                        <div class="title">{{item.name}}</div>
                        <div>
                            <span class="tag" v-for="(tag,tags) in playlist.tags" :key="tags">{{tag}}&#8197;</span>
                             <span class="anthor"><span v-for="(list,index) in item.ar" :key="index">{{list.name}}</span></span>
                        </div>
                    </div>
                </div>
                <div class="right">
                     <router-link :to="{path:'/mvList',query:{id:item.mv,name:item.name}}" v-if="item.mv>0">
                        <svg class="icon" aria-hidden="true" >
                            <use xlink:href="#icon-bofang4"></use>
                        </svg>
                    </router-link>
                    <svg class="icon" aria-hidden="true">
                        <use xlink:href="#icon-liebiao1"></use>
                    </svg>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import { getsize } from '@/utils/utils.js'
export default {
  props: ['playlist'],
  methods: {
    changeValue (num) {
      var res = getsize(num)
      return res
    },
    play (i) {
      if (this.$store.state.playlist !== this.playlist.tracks) {
        this.$store.commit('setPlaylist', this.playlist.tracks)
      }
      this.$store.commit('setPlayIndex', i)
    }
  }
}
</script>
<style lang="less" scoped>
.playList{
    width: 100.11vw;
    padding: 0 0.4rem;
    background-color: white;
    border-top-left-radius:0.3rem;
    border-top-right-radius:0.3rem;
    margin-top: 0.3rem;
    border-bottom: 2px solid #ccc;
    .playList-top{
        display: flex;
        justify-content: space-between;
        height: 1rem;
        align-items: center;
        .left{
            align-items: center;
            display: flex;
            .icon{
                width: 0.6rem;
                height: 0.6rem;
            }
            .title{
                font-size: 0.4rem;
                font-weight: 900;
                margin-left: 0.2rem;
                span{
                    font-size: 0.3rem;
                    color: #ccc;
                }
            }
        }
        .btn{
            font-size: 0.3rem;
            color:white;
            background-color: orangered;
            height: 0.7rem;
            margin: 0.1rem;
            display: flex;
            align-items: center;
            border-radius: 0.4rem;
            margin-top: 0.1rem;
        }
    }
    .list{
        position: fixed;
        top: 6.78rem;
        bottom: 1.2rem;
        left: 0;
        overflow:scroll;
        width: 7.5rem;
        padding: 0 0.4rem;
        background-color: white;
         .playitem{
            display: flex;
            justify-content: space-between;
            align-items: center;
            height: 1rem;
            .left{
                display: flex;
                align-items: center;
                color: #666;
                .index{
                    width: 0.4rem;
                }
                .content{
                    .title{
                        font-size: 0.3rem;
                        font-weight: 900;
                        width: 4rem;
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                    }
                    margin-left: 0.4rem;
                    .tag{
                        font-size: 0.2rem;
                        color:orangered;
                        border: 1px solid orangered;
                        margin-right: 0.1rem;
                    }
                    .anthor{
                        display:inline-block;
                        color: #ccc;
                        font-size: 0.15rem;
                        width: 2rem;
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                    }
                }
            }
            .right{
                .icon{
                    margin:0 0.1rem;
                }
            }
        }
    }
}
</style>
